package com.iqiyi.service.impl;

import com.iqiyi.dto.VideoComment;
import com.iqiyi.mapper.CommentMapper;
import com.iqiyi.po.Comment;
import com.iqiyi.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * TODO
 *  评论的业务层
 * @author YoungKai
 * @date 2021/2/24 11:28
 */
@Service
public class CommentServiceImpl implements CommentService {
    @Autowired(required = false)
    private CommentMapper commentMapper;
    @Override
    public List<Comment> findCommentByVid(int vid) {
        List<Comment> commentByVid = commentMapper.findCommentByVid(vid);
        return commentByVid;
    }

    @Override
    public Comment addComment(Comment comment) {
        int insert = commentMapper.insertSelective(comment);
        if (insert>-1){
            System.out.println("插入评论成功");
            return comment;
        }
        return null;
    }

    @Override
    public int addVideoComment(VideoComment videoComment) {
        int i = commentMapper.addVideoComment(videoComment);
        if (i>-1){
            return i;
        }
        return -1;
    }

    @Override
    public int selectCommentTotal(int vid) {
        int i = commentMapper.selectCommentTotal(vid);
        return i;
    }
}
